<!DOCTYPE html>
<html>
    <head>
        <title>Brython test</title>
        <meta charset="iso-8859-1">
        <script src="../brython.js"></script>
    </head>
    <body onLoad="brython(1)">
        <script type="text/python">
        from html import *
        geo = win.navigator.geolocation

        def navi(pos):
            xyz = pos.coords

            data = {
                'lat':xyz.latitude,
                'lon':xyz.longitude,
                'acc':xyz.accuracy,
                'timestamp': pos.timestamp,
                'alt':xyz.altitude,
                'alt_acc':xyz.altitudeAccuracy,
                'heading':xyz.heading,
                'speed':xyz.speed
            }

            ul = UL()
            for key in data.keys():
                try:
                    string = key + ': ' + str(float(data[key]))
                except ValueError:
                    string = key + ': Could not detect'
                ul <= LI(string)

            doc <= H3("Your position")
            doc <= ul

        def nonavi(error):
            log(error)

        if geo:
            geo.getCurrentPosition(navi, nonavi)
        else:
            alert('geolocation not supported')
        </script>
    </body>
</html>
